package leetcode_2401_2500;

public class LeeCode_2485 {
    public static void main(String[] args) {
        System.out.println(pivotInteger(1));
    }
    private static int pivotInteger(int n) {
        if (n == 1)
            return 1;
        int[] sums = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sums[i] = sums[i - 1] + i;
        }
        for (int i = 1; i <= n; i++) {
            int t = sums[n] - sums[i - 1];
            if (sums[i] == t){
                return i;
            }
        }
        return -1;
    }
}
